# Contributor: Nikita Travkin <nikita@trvn.ru>
# Maintainer: Nikita Travkin <nikita@trvn.ru>
pkgname=dtbloader
pkgver=1.3.0
pkgrel=0
pkgdesc="EFI driver that finds and installs DeviceTree into the UEFI configuration table"
url="https://github.com/TravMurav/dtbloader"
arch="aarch64"
license="BSD-3-Clause"
makedepends="clang cmd:llvm-ar lld"
options="!check"
subpackages="$pkgname-boot-deploy:boot_deploy"
source="https://github.com/TravMurav/dtbloader/releases/download/$pkgver/dtbloader-$pkgver.tar.gz"
builddir="$srcdir"

build() {
	make \
		ABORT_IF_UNSUPPORTED=1 \
		O=build

	./scripts/get_supported_dtbs.sh > "$builddir"/build/dtbs.txt
}

package() {
	install -Dt "$pkgdir"/usr/share/dtbloader \
		"$builddir"/build/dtbloader.efi \
		"$builddir"/build/dtbs.txt
}

boot_deploy() {
	pkgdesc="boot-deploy integration for dtbloader"
	install_if="$pkgname=$pkgver-r$pkgrel boot-deploy"

	mkdir -p "$subpkgdir"/usr/share/boot-deploy/efi-drivers/
	ln -s /usr/share/dtbloader/dtbloader.efi \
		"$subpkgdir"/usr/share/boot-deploy/efi-drivers/dtbloaderaa64.efi
}

sha512sums="
dd7a4ea13fb3c401092432fbc37a0dc37d173ff72dc1e50a88a84a5f7c74670253ffa26b0364f36ed483aef8d09aabee729c787792a1eb5a0c98714a08e860ab  dtbloader-1.3.0.tar.gz
"
